﻿// LSOffset.cs
// Contains a class for an Offset for a load store instruction

using System;


namespace armsim
{
    /// <summary>
    /// Class containing the offset information for a Load/Store instruction
    /// </summary>
    public abstract class LSOffset
    {

        public Boolean IsPositive { get; protected set; }

        /// <summary>
        /// Initializes a new offset
        /// </summary>
        /// <param name="instruction">32bit instruction to be intialized from</param>
        protected LSOffset(uint instruction)
        {
            this.IsPositive = VirtualMemory.ExtractBits(instruction, 23, 23) == 1 ? true : false;
        }

        /// <summary>
        /// Computes the offset value
        /// </summary>
        /// <param name="cpu">VirtualCPU to grab from</param>
        /// <returns>value of the offset</returns>
        public abstract uint ComputeOffset(VirtualCPU cpu);

        /// <summary>
        /// Converts the offset to assembly langauge
        /// </summary>
        /// <param name="cpu">VirtualCPU to grab from</param>
        /// <returns>the assembly string</returns>
        public abstract String ToAssembly(VirtualCPU cpu);

    }
}
